package com.yunhuajinfu.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.yunhuajinfu.R;
import com.yunhuajinfu.entity.RedList;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by ekikousei易皇星 on 16/12/7.
 * E-mail:13764664731@163.com
 * Signature:缘分是本书,翻的不经意会错过,读的太认真会流泪!!
 * <p/>
 * TODO:类描述:
 */
public class PayHongbaolistAdapter extends BaseAdapter {
    private List<RedList> redList;
    private Context context;
    private LayoutInflater layoutInflater;

    public PayHongbaolistAdapter(Context context,List<RedList> redList){
        this.context=context;
        this.redList=redList;
         layoutInflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        if(null==redList){
            redList=new ArrayList<>();
        }
        return redList.size();
    }

    @Override
    public Object getItem(int position) {
        return redList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        convertView= layoutInflater.inflate(R.layout.hongbao_gridview_item,null);
       TextView tv_money_number= (TextView) convertView.findViewById(R.id.tv_money_number);
        RedList info = this.redList.get(position);
        if(info.ischick()==true){
            tv_money_number.setBackgroundColor(context.getResources().getColor(R.color.bule));
        }else{
            tv_money_number.setBackgroundColor(context.getResources().getColor(R.color.gray_a8));
        }
        tv_money_number.setText(info.getRedMoney()+"元");

        return convertView;
    }
}
